//
//  ZYImageOperation.h
//  ZYWebImage
//
//  Created by wangzhipan on 2025/3/5.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ZYWebImageConst.h"

NS_ASSUME_NONNULL_BEGIN

@class ZYImageOperationToken;
@interface ZYImageOperation : NSOperation
@property (nonatomic, strong, readonly, nullable) NSString *urlStr;

- (instancetype)initWithUrl:(nonnull NSString *)urlStr
                    session:(nullable NSURLSession *)session;

/*
 当有一个url对应多个重复任务下载时，只需下载以及解码完毕后，给多个block回调
 
 当取消一个同一个url任务时，不影响其他相同url任务的下载，需要传递这个任务的token
 */
- (ZYImageOperationToken *)addCompletedBlock:(ZYDownloadCompleted)completed;


- (void)cancelSingle:(ZYImageOperationToken *)token;

/// 取消相同url的全部Token任务
- (void)cancel;
@end

NS_ASSUME_NONNULL_END
